package com.jeff.rps;

import java.util.Vector;

public class Game
{
  private final int numRounds;

  private final Player player1;
  private final Player player2;
  private final Vector<Round> history;

  public Game(Player p1, Player p2, int numRounds)
  {
    this.player1 = p1;
    this.player2 = p2;
    this.numRounds = numRounds;
    this.history = new Vector<Round>(numRounds);
  }

  public boolean isOver()
  {
    return history.size() == numRounds;
  }

  public void nextTurn()
  {
    GameHistory gameHistory = getHistory();

    Throw throw1 = player1.makeThrow(gameHistory);
    Throw throw2 = player2.makeThrow(gameHistory);

    history.add(new Round(player1, throw1, player2, throw2));
  }

  public Player getPlayer1()
  {
    return player1;
  }

  public Player getPlayer2()
  {
    return player2;
  }

  public GameHistory getHistory()
  {
    return new GameHistory(history);
  }
}
